home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / info.lzh / INFO / GCC_INFO.2 < prev    next >
Encoding:
GNU Info File  |  1993-10-21  |  47.9 KB  |  1,167 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. File: gcc.info,  Node: C Dialect Options,  Next: C++ Dialect Options,  Prev: Invoking G++,  Up: Invoking GCC
  28.  
  29. Options Controlling C Dialect
  30. =============================
  31.  
  32.    The following options control the dialect of C (or languages derived
  33. from C, such as C++ and Objective C) that the compiler accepts:
  34.  
  35. `-ansi'
  36.      Support all ANSI standard C programs.
  37.  
  38.      This turns off certain features of GNU C that are incompatible
  39.      with ANSI C, such as the `asm', `inline' and `typeof' keywords, and
  40.      predefined macros such as `unix' and `vax' that identify the type
  41.      of system you are using.  It also enables the undesirable and
  42.      rarely used ANSI trigraph feature, and disallows `$' as part of
  43.      identifiers.
  44.  
  45.      The alternate keywords `__asm__', `__extension__', `__inline__'
  46.      and `__typeof__' continue to work despite `-ansi'.  You would not
  47.      want to use them in an ANSI C program, of course, but it useful to
  48.      put them in header files that might be included in compilations
  49.      done with `-ansi'.  Alternate predefined macros such as `__unix__'
  50.      and `__vax__' are also available, with or without `-ansi'.
  51.  
  52.      The `-ansi' option does not cause non-ANSI programs to be rejected
  53.      gratuitously.  For that, `-pedantic' is required in addition to
  54.      `-ansi'.  *Note Warning Options::.
  55.  
  56.      The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
  57.      is used.  Some header files may notice this macro and refrain from
  58.      declaring certain functions or defining certain macros that the
  59.      ANSI standard doesn't call for; this is to avoid interfering with
  60.      any programs that might use these names for other things.
  61.  
  62.      The functions `alloca', `abort', `exit', and `_exit' are not
  63.      builtin functions when `-ansi' is used.
  64.  
  65. `-fno-asm'
  66.      Do not recognize `asm', `inline' or `typeof' as a keyword.  These
  67.      words may then be used as identifiers.  You can use the keywords
  68.      `__asm__', `__inline__' and `__typeof__' instead.  `-ansi' implies
  69.      `-fno-asm'.
  70.  
  71. `-fno-builtin'
  72.      Don't recognize built-in functions that do not begin with two
  73.      leading underscores.  Currently, the functions affected include
  74.      `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
  75.      `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
  76.      `strlen'.
  77.  
  78.      The `-ansi' option prevents `alloca' and `ffs' from being builtin
  79.      functions, since these functions do not have an ANSI standard
  80.      meaning.
  81.  
  82. `-trigraphs'
  83.      Support ANSI C trigraphs.  You don't want to know about this
  84.      brain-damage.  The `-ansi' option implies `-trigraphs'.
  85.  
  86. `-traditional'
  87.      Attempt to support some aspects of traditional C compilers.
  88.      Specifically:
  89.  
  90.         * All `extern' declarations take effect globally even if they
  91.           are written inside of a function definition.  This includes
  92.           implicit declarations of functions.
  93.  
  94.         * The keywords `typeof', `inline', `signed', `const' and
  95.           `volatile' are not recognized.  (You can still use the
  96.           alternative keywords such as `__typeof__', `__inline__', and
  97.           so on.)
  98.  
  99.         * Comparisons between pointers and integers are always allowed.
  100.  
  101.         * Integer types `unsigned short' and `unsigned char' promote to
  102.           `unsigned int'.
  103.  
  104.         * Out-of-range floating point literals are not an error.
  105.  
  106.         * Certain constructs which ANSI regards as a single invalid
  107.           preprocessing number, such as `0xe-0xd', are treated as
  108.           expressions instead.
  109.  
  110.         * String "constants" are not necessarily constant; they are
  111.           stored in writable space, and identical looking constants are
  112.           allocated separately.  (This is the same as the effect of
  113.           `-fwritable-strings'.)
  114.  
  115.         * All automatic variables not declared `register' are preserved
  116.           by `longjmp'.  Ordinarily, GNU C follows ANSI C: automatic
  117.           variables not declared `volatile' may be clobbered.
  118.  
  119.         * In the preprocessor, comments convert to nothing at all,
  120.           rather than to a space.  This allows traditional token
  121.           concatenation.
  122.  
  123.         * In the preprocessor, macro arguments are recognized within
  124.           string constants in a macro definition (and their values are
  125.           stringified, though without additional quote marks, when they
  126.           appear in such a context).  The preprocessor always considers
  127.           a string constant to end at a newline.
  128.  
  129.         * The predefined macro `__STDC__' is not defined when you use
  130.           `-traditional', but `__GNUC__' is (since the GNU extensions
  131.           which `__GNUC__' indicates are not affected by
  132.           `-traditional').  If you need to write header files that work
  133.           differently depending on whether `-traditional' is in use, by
  134.           testing both of these predefined macros you can distinguish
  135.           four situations: GNU C, traditional GNU C, other ANSI C
  136.           compilers, and other old C compilers.  *Note Standard
  137.           Predefined Macros: (cpp.info)Standard Predefined, for more
  138.           discussion of these and other predefined macros.
  139.  
  140.         * The preprocessor considers a string constant to end at a
  141.           newline (unless the newline is escaped with `\').  (Without
  142.           `-traditional', string constants can contain the newline
  143.           character as typed.)
  144.  
  145.         * The character escape sequences `\x' and `\a' evaluate as the
  146.           literal characters `x' and `a' respectively.  Without
  147.           `-traditional', `\x' is a prefix for the hexadecimal
  148.           representation of a character, and `\a' produces a bell.
  149.  
  150.         * In C++ programs, assignment to `this' is permitted with
  151.           `-traditional'.  This is the same as the effect of
  152.           `-fthis-is-variable'.
  153.  
  154.      You may wish to use `-fno-builtin' as well as `-traditional' if
  155.      your program uses names that are normally GNU C builtin functions
  156.      for other purposes of its own.
  157.  
  158. `-traditional-cpp'
  159.      Attempt to support some aspects of traditional C preprocessors.
  160.      This includes the last three items in the table immediately above,
  161.      but none of the other effects of `-traditional'.
  162.  
  163. `-fcond-mismatch'
  164.      Allow conditional expressions with mismatched types in the second
  165.      and third arguments.  The value of such an expression is void.
  166.  
  167. `-funsigned-char'
  168.      Let the type `char' be unsigned, like `unsigned char'.
  169.  
  170.      Each kind of machine has a default for what `char' should be.  It
  171.      is either like `unsigned char' by default or like `signed char' by
  172.      default.
  173.  
  174.      Ideally, a portable program should always use `signed char' or
  175.      `unsigned char' when it depends on the signedness of an object.
  176.      But many programs have been written to use plain `char' and expect
  177.      it to be signed, or expect it to be unsigned, depending on the
  178.      machines they were written for.  This option, and its inverse, let
  179.      you make such a program work with the opposite default.
  180.  
  181.      The type `char' is always a distinct type from each of `signed
  182.      char' or `unsigned char', even though its behavior is always just
  183.      like one of those two.
  184.  
  185. `-fsigned-char'
  186.      Let the type `char' be signed, like `signed char'.
  187.  
  188.      Note that this is equivalent to `-fno-unsigned-char', which is the
  189.      negative form of `-funsigned-char'.  Likewise, the option
  190.      `-fno-signed-char' is equivalent to `-funsigned-char'.
  191.  
  192. `-fsigned-bitfields'
  193. `-funsigned-bitfields'
  194. `-fno-signed-bitfields'
  195. `-fno-unsigned-bitfields'
  196.      These options control whether a bitfield is signed or unsigned,
  197.      when the declaration does not use either `signed' or `unsigned'.
  198.      By default, such a bitfield is signed, because this is consistent:
  199.      the basic integer types such as `int' are signed types.
  200.  
  201.      However, when `-traditional' is used, bitfields are all unsigned
  202.      no matter what.
  203.  
  204. `-fwritable-strings'
  205.      Store string constants in the writable data segment and don't
  206.      uniquize them.  This is for compatibility with old programs which
  207.      assume they can write into string constants.  The option
  208.      `-traditional' also has this effect.
  209.  
  210.      Writing into string constants is a very bad idea; "constants"
  211.      should be constant.
  212.  
  213. File: gcc.info,  Node: C++ Dialect Options,  Next: Warning Options,  Prev: C Dialect Options,  Up: Invoking GCC
  214.  
  215. Options Controlling C++ Dialect
  216. ===============================
  217.  
  218.    This section describes the command-line options that are only
  219. meaningful for C++ programs; but you can also use most of the GNU
  220. compiler options regardless of what language your program is in.  For
  221. example, you might compile a file `firstClass.C' like this:
  222.  
  223.      g++ -g -felide-constructors -O -c firstClass.C
  224.  
  225. In this example, only `-felide-constructors' is an option meant only
  226. for C++ programs; you can use the other options with any language
  227. supported by GNU CC.
  228.  
  229.    Here is a list of options that are *only* for compiling C++ programs:
  230.  
  231. `-fall-virtual'
  232.      Treat all possible member functions as virtual, implicitly.  All
  233.      member functions (except for constructor functions and `new' or
  234.      `delete' member operators) are treated as virtual functions of the
  235.      class where they appear.
  236.  
  237.      This does not mean that all calls to these member functions will
  238.      be made through the internal table of virtual functions.  Under
  239.      some circumstances, the compiler can determine that a call to a
  240.      given virtual function can be made directly; in these cases the
  241.      calls are direct in any case.
  242.  
  243. `-fdollars-in-identifiers'
  244.      Accept `$' in identifiers.  You can also explicitly prohibit use of
  245.      `$' with `-fno-dollars-in-identifiers'.  (GNU C++ allows `$' by
  246.      default on some target systems but not others.)  Traditional C
  247.      allowed the character `$' to form part of identifiers.  However,
  248.      ANSI C and C++ forbid `$' in identifiers.
  249.  
  250. `-felide-constructors'
  251.      Elide constructors when this seems plausible.  With this option,
  252.      GNU C++ initializes `y' directly from the call to `foo' without
  253.      going through a temporary in the following code:
  254.  
  255.           A foo ();
  256.           A y = foo ();
  257.  
  258.      Without this option, GNU C++ (1) initializes `y' by calling the
  259.      appropriate constructor for type `A'; (2) assigns the result of
  260.      `foo' to a temporary; and, finally, (3) replaces the initial value
  261.      of `y' with the temporary.
  262.  
  263.      The default behavior (`-fno-elide-constructors') is specified by
  264.      the draft ANSI C++ standard.  If your program's constructors have
  265.      side effects, `-felide-constructors' can change your program's
  266.      behavior, since some constructor calls may be omitted.
  267.  
  268. `-fenum-int-equiv'
  269.      Permit implicit conversion of `int' to enumeration types.  Normally
  270.      GNU C++ allows conversion of `enum' to `int', but not the other
  271.      way around.
  272.  
  273. `-fmemoize-lookups'
  274. `-fsave-memoized'
  275.      Use heuristics to compile faster.  These heuristics are not
  276.      enabled by default, since they are only effective for certain
  277.      input files.  Other input files compile more slowly.
  278.  
  279.      The first time the compiler must build a call to a member function
  280.      (or reference to a data member), it must (1) determine whether the
  281.      class implements member functions of that name; (2) resolve which
  282.      member function to call (which involves figuring out what sorts of
  283.      type conversions need to be made); and (3) check the visibility of
  284.      the member function to the caller.  All of this adds up to slower
  285.      compilation.  Normally, the second time a call is made to that
  286.      member function (or reference to that data member), it must go
  287.      through the same lengthy process again.  This means that code like
  288.      this:
  289.  
  290.           cout << "This " << p << " has " << n << " legs.\n";
  291.  
  292.      makes six passes through all three steps.  By using a software
  293.      cache, a "hit" significantly reduces this cost.  Unfortunately,
  294.      using the cache introduces another layer of mechanisms which must
  295.      be implemented, and so incurs its own overhead.
  296.      `-fmemoize-lookups' enables the software cache.
  297.  
  298.      Because access privileges (visibility) to members and member
  299.      functions may differ from one function context to the next, G++
  300.      may need to flush the cache.  With the `-fmemoize-lookups' flag,
  301.      the cache is flushed after every function that is compiled.  The
  302.      `-fsave-memoized' flag enables the same software cache, but when
  303.      the compiler determines that the context of the last function
  304.      compiled would yield the same access privileges of the next
  305.      function to compile, it preserves the cache.  This is most helpful
  306.      when defining many member functions for the same class: with the
  307.      exception of member functions which are friends of other classes,
  308.      each member function has exactly the same access privileges as
  309.      every other, and the cache need not be flushed.
  310.  
  311. `-fno-strict-prototype'
  312.      Treat a function declaration with no arguments, such as
  313.      `int foo ();', as C would treat it--as saying nothing about the
  314.      number of arguments or their types.  Normally, such a declaration
  315.      in C++ means that the function `foo' takes no arguments.
  316.  
  317. `-fnonnull-objects'
  318.      Assume that objects reached through references are not null.
  319.  
  320.      Normally, GNU C++ makes conservative assumptions about objects
  321.      reached through references.  For example, the compiler must check
  322.      that `a' is not null in code like the following:
  323.  
  324.           obj &a = g ();
  325.           a.f (2);
  326.  
  327.      Checking that references of this sort have non-null values requires
  328.      extra code, however, and it is unnecessary for many programs.  You
  329.      can use `-fnonnull-objects' to omit the checks for null, if your
  330.      program doesn't require checking.
  331.  
  332. `-fthis-is-variable'
  333.      Permit assignment to `this'.  The incorporation of user-defined
  334.      free store management into C++ has made assignment to `this' an
  335.      anachronism.  Therefore, by default it is invalid to assign to
  336.      `this' within a class member function; that is, GNU C++ treats the
  337.      type of `this' in a member function of class `X' to be `X *const'.
  338.      However, for backwards compatibility, you can make it valid with
  339.      `-fthis-is-variable'.
  340.  
  341. `-nostdinc++'
  342.      Do not search for header files in the standard directories
  343.      specific to C++, but do still search the other standard
  344.      directories.  (This option is used when building libg++.)
  345.  
  346. `-traditional'
  347.      For C++ programs (in addition to the effects that apply to both C
  348.      and C++), this has the same effect as `-fthis-is-variable'.  *Note
  349.      Options Controlling C Dialect: C Dialect Options.
  350.  
  351.    In addition, these optimization, warning, and code generation options
  352. have meanings only for C++ programs:
  353.  
  354. `-fno-default-inline'
  355.      Do not assume `inline' for functions defined inside a class scope.
  356.      *Note Options That Control Optimization: Optimize Options.
  357.  
  358. `-Wenum-clash'
  359. `-Woverloaded-virtual'
  360. `-Wtemplate-debugging'
  361.      Warnings that apply only to C++ programs.  *Note Options to
  362.      Request or Suppress Warnings: Warning Options.
  363.  
  364. `+eN'
  365.      Control how virtual function definitions are used, in a fashion
  366.      compatible with `cfront' 1.x.  *Note Options for Code Generation
  367.      Conventions: Code Gen Options.
  368.  
  369. File: gcc.info,  Node: Warning Options,  Next: Debugging Options,  Prev: C++ Dialect Options,  Up: Invoking GCC
  370.  
  371. Options to Request or Suppress Warnings
  372. =======================================
  373.  
  374.    Warnings are diagnostic messages that report constructions which are
  375. not inherently erroneous but which are risky or suggest there may have
  376. been an error.
  377.  
  378.    You can request many specific warnings with options beginning `-W',
  379. for example `-Wimplicit' to request warnings on implicit declarations.
  380. Each of these specific warning options also has a negative form
  381. beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
  382. This manual lists only one of the two forms, whichever is not the
  383. default.
  384.  
  385.    These options control the amount and kinds of warnings produced by
  386. GNU CC:
  387.  
  388. `-fsyntax-only'
  389.      Check the code for syntax errors, but don't do anything beyond
  390.      that.
  391.  
  392. `-w'
  393.      Inhibit all warning messages.
  394.  
  395. `-Wno-import'
  396.      Inhibit warning messages about the use of `#import'.
  397.  
  398. `-pedantic'
  399.      Issue all the warnings demanded by strict ANSI standard C; reject
  400.      all programs that use forbidden extensions.
  401.  
  402.      Valid ANSI standard C programs should compile properly with or
  403.      without this option (though a rare few will require `-ansi').
  404.      However, without this option, certain GNU extensions and
  405.      traditional C features are supported as well.  With this option,
  406.      they are rejected.
  407.  
  408.      `-pedantic' does not cause warning messages for use of the
  409.      alternate keywords whose names begin and end with `__'.  Pedantic
  410.      warnings are also disabled in the expression that follows
  411.      `__extension__'.  However, only system header files should use
  412.      these escape routes; application programs should avoid them.
  413.      *Note Alternate Keywords::.
  414.  
  415.      This option is not intended to be useful; it exists only to satisfy
  416.      pedants who would otherwise claim that GNU CC fails to support the
  417.      ANSI standard.
  418.  
  419.      Some users try to use `-pedantic' to check programs for strict ANSI
  420.      C conformance.  They soon find that it does not do quite what they
  421.      want: it finds some non-ANSI practices, but not all--only those
  422.      for which ANSI C *requires* a diagnostic.
  423.  
  424.      A feature to report any failure to conform to ANSI C might be
  425.      useful in some instances, but would require considerable
  426.      additional work and would be quite different from `-pedantic'.  We
  427.      recommend, rather, that users take advantage of the extensions of
  428.      GNU C and disregard the limitations of other compilers.  Aside
  429.      from certain supercomputers and obsolete small machines, there is
  430.      less and less reason ever to use any other C compiler other than
  431.      for bootstrapping GNU CC.
  432.  
  433. `-pedantic-errors'
  434.      Like `-pedantic', except that errors are produced rather than
  435.      warnings.
  436.  
  437. `-W'
  438.      Print extra warning messages for these events:
  439.  
  440.         * A nonvolatile automatic variable might be changed by a call to
  441.           `longjmp'.  These warnings as well are possible only in
  442.           optimizing compilation.
  443.  
  444.           The compiler sees only the calls to `setjmp'.  It cannot know
  445.           where `longjmp' will be called; in fact, a signal handler
  446.           could call it at any point in the code.  As a result, you may
  447.           get a warning even when there is in fact no problem because
  448.           `longjmp' cannot in fact be called at the place which would
  449.           cause a problem.
  450.  
  451.         * A function can return either with or without a value.
  452.           (Falling off the end of the function body is considered
  453.           returning without a value.)  For example, this function would
  454.           evoke such a warning:
  455.  
  456.                foo (a)
  457.                {
  458.                  if (a > 0)
  459.                    return a;
  460.                }
  461.  
  462.         * An expression-statement contains no side effects.
  463.  
  464.         * An unsigned value is compared against zero with `>' or `<='.
  465.  
  466.         * A comparison like `x<=y<=z' appears; this is equivalent to
  467.           `(x<=y ? 1 : 0) <= z', which is a different interpretation
  468.           from that of ordinary mathematical notation.
  469.  
  470.         * Storage-class specifiers like `static' are not the first
  471.           things in a declaration.  According to the C Standard, this
  472.           usage is obsolescent.
  473.  
  474.         * An aggregate has a partly bracketed initializer.  For
  475.           example, the following code would evoke such a warning,
  476.           because braces are missing around the initializer for `x.h':
  477.  
  478.                struct s { int f, g; };
  479.                struct t { struct s h; int i; };
  480.                struct t x = { 1, 2, 3 };
  481.  
  482. `-Wimplicit'
  483.      Warn whenever a function or parameter is implicitly declared.
  484.  
  485. `-Wreturn-type'
  486.      Warn whenever a function is defined with a return-type that
  487.      defaults to `int'.  Also warn about any `return' statement with no
  488.      return-value in a function whose return-type is not `void'.
  489.  
  490. `-Wunused'
  491.      Warn whenever a local variable is unused aside from its
  492.      declaration, whenever a function is declared static but never
  493.      defined, and whenever a statement computes a result that is
  494.      explicitly not used.
  495.  
  496.      If you want to prevent a warning for a particular variable, you
  497.      can use this macro:
  498.  
  499.           #define USE(var) \
  500.             static void * use_##var = (&use_##var, (void *) &var)
  501.           
  502.           USE (string);
  503.  
  504. `-Wswitch'
  505.      Warn whenever a `switch' statement has an index of enumeral type
  506.      and lacks a `case' for one or more of the named codes of that
  507.      enumeration.  (The presence of a `default' label prevents this
  508.      warning.)  `case' labels outside the enumeration range also
  509.      provoke warnings when this option is used.
  510.  
  511. `-Wcomment'
  512.      Warn whenever a comment-start sequence `/*' appears in a comment.
  513.  
  514. `-Wtrigraphs'
  515.      Warn if any trigraphs are encountered (assuming they are enabled).
  516.  
  517. `-Wformat'
  518.      Check calls to `printf' and `scanf', etc., to make sure that the
  519.      arguments supplied have types appropriate to the format string
  520.      specified.
  521.  
  522. `-Wchar-subscripts'
  523.      Warn if an array subscript has type `char'.  This is a common cause
  524.      of error, as programmers often forget that this type is signed on
  525.      some machines.
  526.  
  527. `-Wuninitialized'
  528.      An automatic variable is used without first being initialized.
  529.  
  530.      These warnings are possible only in optimizing compilation,
  531.      because they require data flow information that is computed only
  532.      when optimizing.  If you don't specify `-O', you simply won't get
  533.      these warnings.
  534.  
  535.      These warnings occur only for variables that are candidates for
  536.      register allocation.  Therefore, they do not occur for a variable
  537.      that is declared `volatile', or whose address is taken, or whose
  538.      size is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
  539.      structures, unions or arrays, even when they are in registers.
  540.  
  541.      Note that there may be no warning about a variable that is used
  542.      only to compute a value that itself is never used, because such
  543.      computations may be deleted by data flow analysis before the
  544.      warnings are printed.
  545.  
  546.      These warnings are made optional because GNU CC is not smart
  547.      enough to see all the reasons why the code might be correct
  548.      despite appearing to have an error.  Here is one example of how
  549.      this can happen:
  550.  
  551.           {
  552.             int x;
  553.             switch (y)
  554.               {
  555.               case 1: x = 1;
  556.                 break;
  557.               case 2: x = 4;
  558.                 break;
  559.               case 3: x = 5;
  560.               }
  561.             foo (x);
  562.           }
  563.  
  564.      If the value of `y' is always 1, 2 or 3, then `x' is always
  565.      initialized, but GNU CC doesn't know this.  Here is another common
  566.      case:
  567.  
  568.           {
  569.             int save_y;
  570.             if (change_y) save_y = y, y = new_y;
  571.             ...
  572.             if (change_y) y = save_y;
  573.           }
  574.  
  575.      This has no bug because `save_y' is used only if it is set.
  576.  
  577.      Some spurious warnings can be avoided if you declare all the
  578.      functions you use that never return as `volatile'.  *Note Function
  579.      Attributes::.
  580.  
  581. `-Wparentheses'
  582.      Warn if parentheses are omitted in certain contexts, such as when
  583.      there is an assignment in a context where a truth value is
  584.      expected, or when operators are nested whose precedence people
  585.      often get confused about.
  586.  
  587. `-Wenum-clash'
  588.      Warn about conversion between different enumeration types.  (C++
  589.      only).
  590.  
  591. `-Wtemplate-debugging'
  592.      When using templates in a C++ program, warn if debugging is not yet
  593.      fully available (C++ only).
  594.  
  595. `-Wall'
  596.      All of the above `-W' options combined.  These are all the options
  597.      which pertain to usage that we recommend avoiding and that we
  598.      believe is easy to avoid, even in conjunction with macros.
  599.  
  600.    The remaining `-W...' options are not implied by `-Wall' because
  601. they warn about constructions that we consider reasonable to use, on
  602. occasion, in clean programs.
  603.  
  604. `-Wtraditional'
  605.      Warn about certain constructs that behave differently in
  606.      traditional and ANSI C.
  607.  
  608.         * Macro arguments occurring within string constants in the
  609.           macro body.  These would substitute the argument in
  610.           traditional C, but are part of the constant in ANSI C.
  611.  
  612.         * A function declared external in one block and then used after
  613.           the end of the block.
  614.  
  615.         * A `switch' statement has an operand of type `long'.
  616.  
  617. `-Wshadow'
  618.      Warn whenever a local variable shadows another local variable.
  619.  
  620. `-Wid-clash-LEN'
  621.      Warn whenever two distinct identifiers match in the first LEN
  622.      characters.  This may help you prepare a program that will compile
  623.      with certain obsolete, brain-damaged compilers.
  624.  
  625. `-Wpointer-arith'
  626.      Warn about anything that depends on the "size of" a function type
  627.      or of `void'.  GNU C assigns these types a size of 1, for
  628.      convenience in calculations with `void *' pointers and pointers to
  629.      functions.
  630.  
  631. `-Wcast-qual'
  632.      Warn whenever a pointer is cast so as to remove a type qualifier
  633.      from the target type.  For example, warn if a `const char *' is
  634.      cast to an ordinary `char *'.
  635.  
  636. `-Wcast-align'
  637.      Warn whenever a pointer is cast such that the required alignment
  638.      of the target is increased.  For example, warn if a `char *' is
  639.      cast to an `int *' on machines where integers can only be accessed
  640.      at two- or four-byte boundaries.
  641.  
  642. `-Wwrite-strings'
  643.      Give string constants the type `const char[LENGTH]' so that
  644.      copying the address of one into a non-`const' `char *' pointer
  645.      will get a warning.  These warnings will help you find at compile
  646.      time code that can try to write into a string constant, but only
  647.      if you have been very careful about using `const' in declarations
  648.      and prototypes.  Otherwise, it will just be a nuisance; this is
  649.      why we did not make `-Wall' request these warnings.
  650.  
  651. `-Wconversion'
  652.      Warn if a prototype causes a type conversion that is different
  653.      from what would happen to the same argument in the absence of a
  654.      prototype.  This includes conversions of fixed point to floating
  655.      and vice versa, and conversions changing the width or signedness
  656.      of a fixed point argument except when the same as the default
  657.      promotion.
  658.  
  659.      Also, warn if a negative integer constant expression is implicitly
  660.      converted to an unsigned type.  For example, warn about the
  661.      assignment `x = -1' if `x' is unsigned.  But do not warn about
  662.      explicit casts like `(unsigned) -1'.
  663.  
  664. `-Waggregate-return'
  665.      Warn if any functions that return structures or unions are defined
  666.      or called.  (In languages where you can return an array, this also
  667.      elicits a warning.)
  668.  
  669. `-Wstrict-prototypes'
  670.      Warn if a function is declared or defined without specifying the
  671.      argument types.  (An old-style function definition is permitted
  672.      without a warning if preceded by a declaration which specifies the
  673.      argument types.)
  674.  
  675. `-Wmissing-prototypes'
  676.      Warn if a global function is defined without a previous prototype
  677.      declaration.  This warning is issued even if the definition itself
  678.      provides a prototype.  The aim is to detect global functions that
  679.      fail to be declared in header files.
  680.  
  681. `-Wredundant-decls'
  682.      Warn if anything is declared more than once in the same scope,
  683.      even in cases where multiple declaration is valid and changes
  684.      nothing.
  685.  
  686. `-Wnested-externs'
  687.      Warn if an `extern' declaration is encountered within an function.
  688.  
  689. `-Winline'
  690.      Warn if a function can not be inlined, and either it was declared
  691.      as inline, or else the `-finline-functions' option was given.
  692.  
  693. `-Woverloaded-virtual'
  694.      Warn when a derived class function declaration may be an error in
  695.      defining a virtual function (C++ only).  In a derived class, the
  696.      definitions of virtual functions must match the type signature of a
  697.      virtual function declared in the base class.  With this option, the
  698.      compiler warns when you define a function with the same name as a
  699.      virtual function, but with a type signature that does not match any
  700.      declarations from the base class.
  701.  
  702. `-Werror'
  703.      Make all warnings into errors.
  704.  
  705. File: gcc.info,  Node: Debugging Options,  Next: Optimize Options,  Prev: Warning Options,  Up: Invoking GCC
  706.  
  707. Options for Debugging Your Program or GNU CC
  708. ============================================
  709.  
  710.    GNU CC has various special options that are used for debugging
  711. either your program or GCC:
  712.  
  713. `-g'
  714.      Produce debugging information in the operating system's native
  715.      format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
  716.      debugging information.
  717.  
  718.      On most systems that use stabs format, `-g' enables use of extra
  719.      debugging information that only GDB can use; this extra information
  720.      makes debugging work better in GDB but will probably make other
  721.      debuggers crash or refuse to read the program.  If you want to
  722.      control for certain whether to generate the extra information, use
  723.      `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+', or
  724.      `-gdwarf' (see below).
  725.  
  726.      Unlike most other C compilers, GNU CC allows you to use `-g' with
  727.      `-O'.  The shortcuts taken by optimized code may occasionally
  728.      produce surprising results: some variables you declared may not
  729.      exist at all; flow of control may briefly move where you did not
  730.      expect it; some statements may not be executed because they
  731.      compute constant results or their values were already at hand;
  732.      some statements may execute in different places because they were
  733.      moved out of loops.
  734.  
  735.      Nevertheless it proves possible to debug optimized output.  This
  736.      makes it reasonable to use the optimizer for programs that might
  737.      have bugs.
  738.  
  739.      The following options are useful when GNU CC is generated with the
  740.      capability for more than one debugging format.
  741.  
  742. `-ggdb'
  743.      Produce debugging information in the native format (if that is
  744.      supported), including GDB extensions if at all possible.
  745.  
  746. `-gstabs'
  747.      Produce debugging information in stabs format (if that is
  748.      supported), without GDB extensions.  This is the format used by
  749.      DBX on most BSD systems.
  750.  
  751. `-gstabs+'
  752.      Produce debugging information in stabs format (if that is
  753.      supported), using GNU extensions understood only by the GNU
  754.      debugger (GDB).  The use of these extensions is likely to make
  755.      other debuggers crash or refuse to read the program.
  756.  
  757. `-gcoff'
  758.      Produce debugging information in COFF format (if that is
  759.      supported).  This is the format used by SDB on most System V
  760.      systems prior to System V Release 4.
  761.  
  762. `-gxcoff'
  763.      Produce debugging information in XCOFF format (if that is
  764.      supported).  This is the format used by the DBX debugger on IBM
  765.      RS/6000 systems.
  766.  
  767. `-gxcoff+'
  768.      Produce debugging information in XCOFF format (if that is
  769.      supported), using GNU extensions understood only by the GNU
  770.      debugger (GDB).  The use of these extensions is likely to make
  771.      other debuggers crash or refuse to read the program.
  772.  
  773. `-gdwarf'
  774.      Produce debugging information in DWARF format (if that is
  775.      supported).  This is the format used by SDB on most System V
  776.      Release 4 systems.
  777.  
  778. `-gdwarf+'
  779.      Produce debugging information in DWARF format (if that is
  780.      supported), using GNU extensions understood only by the GNU
  781.      debugger (GDB).  The use of these extensions is likely to make
  782.      other debuggers crash or refuse to read the program.
  783.  
  784. `-gLEVEL'
  785. `-ggdbLEVEL'
  786. `-gstabsLEVEL'
  787. `-gcoffLEVEL'
  788. `-gxcoffLEVEL'
  789. `-gdwarfLEVEL'
  790.      Request debugging information and also use LEVEL to specify how
  791.      much information.  The default level is 2.
  792.  
  793.      Level 1 produces minimal information, enough for making backtraces
  794.      in parts of the program that you don't plan to debug.  This
  795.      includes descriptions of functions and external variables, but no
  796.      information about local variables and no line numbers.
  797.  
  798.      Level 3 includes extra information, such as all the macro
  799.      definitions present in the program.  Some debuggers support macro
  800.      expansion when you use `-g3'.
  801.  
  802. `-p'
  803.      Generate extra code to write profile information suitable for the
  804.      analysis program `prof'.  You must use this option when compiling
  805.      the source files you want data about, and you must also use it when
  806.      linking.
  807.  
  808. `-pg'
  809.      Generate extra code to write profile information suitable for the
  810.      analysis program `gprof'.  You must use this option when compiling
  811.      the source files you want data about, and you must also use it when
  812.      linking.
  813.  
  814. `-a'
  815.      Generate extra code to write profile information for basic blocks,
  816.      which will record the number of times each basic block is executed.
  817.      This data could be analyzed by a program like `tcov'.  Note,
  818.      however, that the format of the data is not what `tcov' expects.
  819.      Eventually GNU `gprof' should be extended to process this data.
  820.  
  821. `-dLETTERS'
  822.      Says to make debugging dumps during compilation at times specified
  823.      by LETTERS.  This is used for debugging the compiler.  The file
  824.      names for most of the dumps are made by appending a word to the
  825.      source file name (e.g.  `foo.c.rtl' or `foo.c.jump').  Here are the
  826.      possible letters for use in LETTERS, and their meanings:
  827.  
  828.     `M'
  829.           Dump all macro definitions, at the end of preprocessing, and
  830.           write no output.
  831.  
  832.     `N'
  833.           Dump all macro names, at the end of preprocessing.
  834.  
  835.     `D'
  836.           Dump all macro definitions, at the end of preprocessing, in
  837.           addition to normal output.
  838.  
  839.     `y'
  840.           Dump debugging information during parsing, to standard error.
  841.  
  842.     `r'
  843.           Dump after RTL generation, to `FILE.rtl'.
  844.  
  845.     `x'
  846.           Just generate RTL for a function instead of compiling it.
  847.           Usually used with `r'.
  848.  
  849.     `j'
  850.           Dump after first jump optimization, to `FILE.jump'.
  851.  
  852.     `s'
  853.           Dump after CSE (including the jump optimization that sometimes
  854.           follows CSE), to `FILE.cse'.
  855.  
  856.     `L'
  857.           Dump after loop optimization, to `FILE.loop'.
  858.  
  859.     `t'
  860.           Dump after the second CSE pass (including the jump
  861.           optimization that sometimes follows CSE), to `FILE.cse2'.
  862.  
  863.     `f'
  864.           Dump after flow analysis, to `FILE.flow'.
  865.  
  866.     `c'
  867.           Dump after instruction combination, to
  868.           `FILE.combine'.
  869.  
  870.     `S'
  871.           Dump after the first instruction scheduling pass, to
  872.           `FILE.sched'.
  873.  
  874.     `l'
  875.           Dump after local register allocation, to
  876.           `FILE.lreg'.
  877.  
  878.     `g'
  879.           Dump after global register allocation, to
  880.           `FILE.greg'.
  881.  
  882.     `R'
  883.           Dump after the second instruction scheduling pass, to
  884.           `FILE.sched2'.
  885.  
  886.     `J'
  887.           Dump after last jump optimization, to `FILE.jump2'.
  888.  
  889.     `d'
  890.           Dump after delayed branch scheduling, to `FILE.dbr'.
  891.  
  892.     `k'
  893.           Dump after conversion from registers to stack, to
  894.           `FILE.stack'.
  895.  
  896.     `a'
  897.           Produce all the dumps listed above.
  898.  
  899.     `m'
  900.           Print statistics on memory usage, at the end of the run, to
  901.           standard error.
  902.  
  903.     `p'
  904.           Annotate the assembler output with a comment indicating which
  905.           pattern and alternative was used.
  906.  
  907. `-fpretend-float'
  908.      When running a cross-compiler, pretend that the target machine
  909.      uses the same floating point format as the host machine.  This
  910.      causes incorrect output of the actual floating constants, but the
  911.      actual instruction sequence will probably be the same as GNU CC
  912.      would make when running on the target machine.
  913.  
  914. `-save-temps'
  915.      Store the usual "temporary" intermediate files permanently; place
  916.      them in the current directory and name them based on the source
  917.      file.  Thus, compiling `foo.c' with `-c -save-temps' would produce
  918.      files `foo.i' and `foo.s', as well as `foo.o'.
  919.  
  920. `-print-libgcc-file-name'
  921.      Print the full absolute name of the library file `libgcc.a' that
  922.      would be used when linking--and don't do anything else.  With this
  923.      option, GNU CC does not compile or link anything; it just prints
  924.      the file name.
  925.  
  926.      This is useful when you use `-nostdlib' but you do want to link
  927.      with `libgcc.a'.  You can do
  928.  
  929.           gcc -nostdlib FILES... `gcc -print-libgcc-file-name`
  930.  
  931. File: gcc.info,  Node: Optimize Options,  Next: Preprocessor Options,  Prev: Debugging Options,  Up: Invoking GCC
  932.  
  933. Options That Control Optimization
  934. =================================
  935.  
  936.    These options control various sorts of optimizations:
  937.  
  938. `-O'
  939. `-O1'
  940.      Optimize.  Optimizing compilation takes somewhat more time, and a
  941.      lot more memory for a large function.
  942.  
  943.      Without `-O', the compiler's goal is to reduce the cost of
  944.      compilation and to make debugging produce the expected results.
  945.      Statements are independent: if you stop the program with a
  946.      breakpoint between statements, you can then assign a new value to
  947.      any variable or change the program counter to any other statement
  948.      in the function and get exactly the results you would expect from
  949.      the source code.
  950.  
  951.      Without `-O', only variables declared `register' are allocated in
  952.      registers.  The resulting compiled code is a little worse than
  953.      produced by PCC without `-O'.
  954.  
  955.      With `-O', the compiler tries to reduce code size and execution
  956.      time.
  957.  
  958.      When `-O' is specified, the two options `-fthread-jumps' and
  959.      `-fdelayed-branch' are turned on.  On some machines other flags may
  960.      also be turned on.
  961.  
  962. `-O2'
  963.      Optimize even more.  Nearly all supported optimizations that do not
  964.      involve a space-speed tradeoff are performed.  As compared to `-O',
  965.      this option increases both compilation time and the performance of
  966.      the generated code.
  967.  
  968.      `-O2' turns on all `-fFLAG' options that enable more optimization,
  969.      except for `-funroll-loops', `-funroll-all-loops' and
  970.      `-fomit-frame-pointer'.
  971.  
  972. `-O0'
  973.      Do not optimize.
  974.  
  975.      If you use multiple `-O' options, with or without level numbers,
  976.      the last such option is the one that is effective.
  977.  
  978.    Options of the form `-fFLAG' specify machine-independent flags.
  979. Most flags have both positive and negative forms; the negative form of
  980. `-ffoo' would be `-fno-foo'.  In the table below, only one of the forms
  981. is listed--the one which is not the default.  You can figure out the
  982. other form by either removing `no-' or adding it.
  983.  
  984. `-ffloat-store'
  985.      Do not store floating point variables in registers, and inhibit
  986.      other options that might change whether a floating point value is
  987.      taken from a register or memory.
  988.  
  989.      This option prevents undesirable excess precision on machines such
  990.      as the 68000 where the floating registers (of the 68881) keep more
  991.      precision than a `double' is supposed to have.  For most programs,
  992.      the excess precision does only good, but a few programs rely on the
  993.      precise definition of IEEE floating point.  Use `-ffloat-store' for
  994.      such programs.
  995.  
  996. `-fno-default-inline'
  997.      Do not make member functions inline by default merely because they
  998.      are defined inside the class scope (C++ only).  Otherwise, when
  999.      you specify `-O', member functions defined inside class scope are
  1000.      compiled inline by default; i.e., you don't need to add `inline'
  1001.      in front of the member function name.
  1002.  
  1003. `-fno-defer-pop'
  1004.      Always pop the arguments to each function call as soon as that
  1005.      function returns.  For machines which must pop arguments after a
  1006.      function call, the compiler normally lets arguments accumulate on
  1007.      the stack for several function calls and pops them all at once.
  1008.  
  1009. `-fforce-mem'
  1010.      Force memory operands to be copied into registers before doing
  1011.      arithmetic on them.  This may produce better code by making all
  1012.      memory references potential common subexpressions.  When they are
  1013.      not common subexpressions, instruction combination should
  1014.      eliminate the separate register-load.  I am interested in hearing
  1015.      about the difference this makes.
  1016.  
  1017. `-fforce-addr'
  1018.      Force memory address constants to be copied into registers before
  1019.      doing arithmetic on them.  This may produce better code just as
  1020.      `-fforce-mem' may.  I am interested in hearing about the
  1021.      difference this makes.
  1022.  
  1023. `-fomit-frame-pointer'
  1024.      Don't keep the frame pointer in a register for functions that
  1025.      don't need one.  This avoids the instructions to save, set up and
  1026.      restore frame pointers; it also makes an extra register available
  1027.      in many functions.  *It also makes debugging impossible on some
  1028.      machines.*
  1029.  
  1030.      On some machines, such as the Vax, this flag has no effect, because
  1031.      the standard calling sequence automatically handles the frame
  1032.      pointer and nothing is saved by pretending it doesn't exist.  The
  1033.      machine-description macro `FRAME_POINTER_REQUIRED' controls
  1034.      whether a target machine supports this flag.  *Note Registers::.
  1035.  
  1036. `-fno-inline'
  1037.      Don't pay attention to the `inline' keyword.  Normally this option
  1038.      is used to keep the compiler from expanding any functions inline.
  1039.      Note that if you are not optimizing, no functions can be expanded
  1040.      inline.
  1041.  
  1042. `-finline-functions'
  1043.      Integrate all simple functions into their callers.  The compiler
  1044.      heuristically decides which functions are simple enough to be worth
  1045.      integrating in this way.
  1046.  
  1047.      If all calls to a given function are integrated, and the function
  1048.      is declared `static', then the function is normally not output as
  1049.      assembler code in its own right.
  1050.  
  1051. `-fkeep-inline-functions'
  1052.      Even if all calls to a given function are integrated, and the
  1053.      function is declared `static', nevertheless output a separate
  1054.      run-time callable version of the function.
  1055.  
  1056. `-fno-function-cse'
  1057.      Do not put function addresses in registers; make each instruction
  1058.      that calls a constant function contain the function's address
  1059.      explicitly.
  1060.  
  1061.      This option results in less efficient code, but some strange hacks
  1062.      that alter the assembler output may be confused by the
  1063.      optimizations performed when this option is not used.
  1064.  
  1065. `-ffast-math'
  1066.      This option allows GCC to violate some ANSI or IEEE rules and/or
  1067.      specifications in the interest of optimizing code for speed.  For
  1068.      example, it allows the compiler to assume arguments to the `sqrt'
  1069.      function are non-negative numbers.
  1070.  
  1071.      This option should never be turned on by any `-O' option since it
  1072.      can result in incorrect output for programs which depend on an
  1073.      exact implementation of IEEE or ANSI rules/specifications for math
  1074.      functions.
  1075.  
  1076.    The following options control specific optimizations.  The `-O2'
  1077. option turns on all of these optimizations except `-funroll-loops' and
  1078. `-funroll-all-loops'.  On most machines, the `-O' option turns on the
  1079. `-fthread-jumps' and `-fdelayed-branch' options, but specific machines
  1080. may handle it differently.
  1081.  
  1082.    You can use the following flags in the rare cases when "fine-tuning"
  1083. of optimizations to be performed is desired.
  1084.  
  1085. `-fstrength-reduce'
  1086.      Perform the optimizations of loop strength reduction and
  1087.      elimination of iteration variables.
  1088.  
  1089. `-fthread-jumps'
  1090.      Perform optimizations where we check to see if a jump branches to a
  1091.      location where another comparison subsumed by the first is found.
  1092.      If so, the first branch is redirected to either the destination of
  1093.      the second branch or a point immediately following it, depending
  1094.      on whether the condition is known to be true or false.
  1095.  
  1096. `-fcse-follow-jumps'
  1097.      In common subexpression elimination, scan through jump instructions
  1098.      when the target of the jump is not reached by any other path.  For
  1099.      example, when CSE encounters an `if' statement with an `else'
  1100.      clause, CSE will follow the jump when the condition tested is
  1101.      false.
  1102.  
  1103. `-fcse-skip-blocks'
  1104.      This is similar to `-fcse-follow-jumps', but causes CSE to follow
  1105.      jumps which conditionally skip over blocks.  When CSE encounters a
  1106.      simple `if' statement with no else clause, `-fcse-skip-blocks'
  1107.      causes CSE to follow the jump around the body of the `if'.
  1108.  
  1109. `-frerun-cse-after-loop'
  1110.      Re-run common subexpression elimination after loop optimizations
  1111.      has been performed.
  1112.  
  1113. `-fexpensive-optimizations'
  1114.      Perform a number of minor optimizations that are relatively
  1115.      expensive.
  1116.  
  1117. `-fdelayed-branch'
  1118.      If supported for the target machine, attempt to reorder
  1119.      instructions to exploit instruction slots available after delayed
  1120.      branch instructions.
  1121.  
  1122. `-fschedule-insns'
  1123.      If supported for the target machine, attempt to reorder
  1124.      instructions to eliminate execution stalls due to required data
  1125.      being unavailable.  This helps machines that have slow floating
  1126.      point or memory load instructions by allowing other instructions
  1127.      to be issued until the result of the load or floating point
  1128.      instruction is required.
  1129.  
  1130. `-fschedule-insns2'
  1131.      Similar to `-fschedule-insns', but requests an additional pass of
  1132.      instruction scheduling after register allocation has been done.
  1133.      This is especially useful on machines with a relatively small
  1134.      number of registers and where memory load instructions take more
  1135.      than one cycle.
  1136.  
  1137. `-fcaller-saves'
  1138.      Enable values to be allocated in registers that will be clobbered
  1139.      by function calls, by emitting extra instructions to save and
  1140.      restore the registers around such calls.  Such allocation is done
  1141.      only when it seems to result in better code than would otherwise
  1142.      be produced.
  1143.  
  1144.      This option is enabled by default on certain machines, usually
  1145.      those which have no call-preserved registers to use instead.
  1146.  
  1147. `-funroll-loops'
  1148.      Perform the optimization of loop unrolling.  This is only done for
  1149.      loops whose number of iterations can be determined at compile time
  1150.      or run time.  `-funroll-loop' implies `-fstrength-reduce' and
  1151.      `-frerun-cse-after-loop'.
  1152.  
  1153. `-funroll-all-loops'
  1154.      Perform the optimization of loop unrolling.  This is done for all
  1155.      loops and usually makes programs run more slowly.
  1156.      `-funroll-all-loops' implies `-fstrength-reduce' and
  1157.      `-frerun-cse-after-loop'.
  1158.  
  1159. `-fno-peephole'
  1160.      Disable any machine-specific peephole optimizations.
  1161.  
  1162. ə